package com.smooware.icms.app;

import android.os.Bundle;
import android.support.v4.view.MenuItem;
import android.util.Log;

import com.smooware.icms.R;
import com.smooware.icms.fragment.navigation.AbstractFragmentNavigator;
import com.smooware.icms.fragment.navigation.WOFragmentNavigator;

public class WorkOrderActivity extends ICMSLauncherActivity {

	private static final String TAG = WorkOrderActivity.class.getSimpleName();

	private WOFragmentNavigator fragmentNavigator;

	@Override
	public void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		Log.d(TAG, "onCreate");

		setContentView(R.layout.wo_activity);

		fragmentNavigator = (WOFragmentNavigator) abstractFragmentNavigator;

		if (application.getICMSSecurityManager().isTrustedAccess()
				&& savedInstanceState == null) {
			fragmentNavigator.goToWODashboardFragment();
		}
	}

	@Override
	protected AbstractFragmentNavigator initFragmentNavigator() {
		return new WOFragmentNavigator(this);
	}

	@Override
	public boolean onOptionsItemSelected(final MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			fragmentNavigator.goToWODashboardFragment();
			return true;
		default:
			return false;
		}
	}

	@Override
	protected void initActionBar() {
		setTheme(R.style.Theme_SherlockCustom);
	}

	public WOFragmentNavigator getFragmentNavigator() {
		return fragmentNavigator;
	}
}